/* How to iterate through masterList:
 * for (i = masterList.begin(); i != masterList.end(); ++i)
 *      (*i) // current item
 */


#include "Universe.h"
using namespace ms;

Universe::Universe() {
	//timeScale = .000001; // some default, sould be gotten from user
	paused = true; 
	collision = false;
}

void Universe::update(double timeScale_) {
	if (!paused) {
		timeScale = timeScale_;
		for (i = masterList.begin(); i != masterList.end(); ++i)
			i -> updateTerms(timeScale);
		for (i = masterList.begin(); i != masterList.end(); ++i)
			i -> updateLocation(timeScale, collision);
	}
}

void Universe::setPaused(bool p) {
	paused = p;
}

bool Universe::getPaused() {
	return paused;
}

void Universe::setCollision(bool c) {
	collision = c;
}

bool Universe::getCollision() {
	return collision;
}

CircleMass * Universe::addCircleMass(real x_, real y_, real radius_, real mass_, real vx_, real vy_) {
	masterList.push_front(CircleMass(&masterList, x_, y_, radius_, mass_, vx_, vy_));
	return &masterList.front();
	//return static_cast<CircleMass *>(&masterList.front());
}

void Universe::setTimeScale(double timeScale_) {
	timeScale = timeScale_;
}

double Universe::getTimeScale() {
	return timeScale;
}

std::list<CircleMass> * Universe::getMasterListPtr() {
	return &masterList;
}
